﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;

namespace PairingMatrix.View
{
    /// <summary>
    /// Interaction logic for ImageButton.xaml
    /// </summary>
    public partial class TabSelectButton : UserControl
    {
        public event EventHandler Selected;

        public TabSelectButton()
        {
            InitializeComponent();
        }

        public string Text
        {
            set
            {
                caption.Text = value;
            }
        }

        public bool _isSelected; 
        public bool IsSelected 
        {
            get { return _isSelected; }
            set 
            { 
                _isSelected = value;
                if(_isSelected)
                    SetButtonAsSelected();
                else
                    SetButtonAsDeselected();
            }
        }

        private void SetButtonAsDeselected()
        {
            Opacity = 0.6;
            scaleTransform.ScaleX = 0.9;
            scaleTransform.ScaleY = 0.9;
            shadow.Opacity = 0;
        }

        private void SetButtonAsSelected()
        {
            Opacity = 1;
            scaleTransform.ScaleX = 1;
            scaleTransform.ScaleY = 1;
            shadow.Opacity = 1;
            if (Selected != null)
                Selected(this, new EventArgs());

        }

        public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand),
     typeof(UserControl), new PropertyMetadata(null));

        public ICommand Command
        {
            get { return (ICommand)GetValue(CommandProperty); }
            set { SetValue(CommandProperty, value); }
        }
    }
}
